package com.zx.zxblog.controller.admin;

import com.zx.zxblog.entity.dto.LoginDTO;
import com.zx.zxblog.mapper.BlogMapper;
import com.zx.zxblog.mapper.UserMapper;
import com.zx.zxblog.service.UserService;
import com.zx.zxblog.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import javax.validation.Valid;

@Controller
public class AdminLoginController {
    @Autowired
    private BlogMapper blogMapper;
    @Autowired
    private UserService userService;

    @GetMapping("/login")
    public String loginPage(){
        return "admin/login";
    }

    @ResponseBody
    @PostMapping("/login")
    public R login(@RequestBody @Valid LoginDTO loginDTO, HttpSession session){
        System.out.println(loginDTO.getPassword());
        return userService.login(loginDTO,session);

    }

}
